package com.ruoyi.web.controller.Tour;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TourTravelNotesType;
import com.ruoyi.system.service.ITourTravelNotesTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 游记类型Controller
 *
 * @author once
 * @date 2020-10-02
 */
@RestController
@RequestMapping("/Tour/travetype")
public class TourTravelNotesTypeController extends BaseController
{
    @Autowired
    private ITourTravelNotesTypeService tourTravelNotesTypeService;

    /**
     * 查询游记类型列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(TourTravelNotesType tourTravelNotesType)
    {
        startPage();
        List<TourTravelNotesType> list = tourTravelNotesTypeService.selectTourTravelNotesTypeList(tourTravelNotesType);
        return getDataTable(list);
    }

    /**
     * 导出游记类型列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:export')")
    @Log(title = "游记类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TourTravelNotesType tourTravelNotesType)
    {
        List<TourTravelNotesType> list = tourTravelNotesTypeService.selectTourTravelNotesTypeList(tourTravelNotesType);
        ExcelUtil<TourTravelNotesType> util = new ExcelUtil<TourTravelNotesType>(TourTravelNotesType.class);
        return util.exportExcel(list, "type");
    }

    /**
     * 获取游记类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:query')")
    @GetMapping(value = "/{travelNotesId}")
    public AjaxResult getInfo(@PathVariable("travelNotesId") Long travelNotesId)
    {
        return AjaxResult.success(tourTravelNotesTypeService.selectTourTravelNotesTypeById(travelNotesId));
    }

    /**
     * 新增游记类型
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:add')")
    @Log(title = "游记类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourTravelNotesType tourTravelNotesType)
    {
        return toAjax(tourTravelNotesTypeService.insertTourTravelNotesType(tourTravelNotesType));
    }

    /**
     * 修改游记类型
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:edit')")
    @Log(title = "游记类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourTravelNotesType tourTravelNotesType)
    {
        return toAjax(tourTravelNotesTypeService.updateTourTravelNotesType(tourTravelNotesType));
    }

    /**
     * 删除游记类型
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:remove')")
    @Log(title = "游记类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{travelNotesIds}")
    public AjaxResult remove(@PathVariable Long[] travelNotesIds)
    {
        return toAjax(tourTravelNotesTypeService.deleteTourTravelNotesTypeByIds(travelNotesIds));
    }
}
